package com.bjpowernode.springboot.service.Impl;

import com.bjpowernode.springboot.dao.TestMapper;
import com.bjpowernode.springboot.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;


@Service // 注入到spring容器中
public class TestServiceImpl implements TestService {

    @Autowired
    private RedisTemplate<Object, Object> redisTemplate; // 注入redis的模板对象

    @Autowired
    private TestMapper testMapper; // 测试mapper，从测试表中获取数据


    @Override
    public boolean test_mysql_connect() {
        boolean test_info = testMapper.queryTestData();
        return test_info;
    }

    @Override
    public boolean test_redis_connect() {
        ValueOperations<Object, Object> ops = redisTemplate.opsForValue();
        Object k2 = ops.get("k2");
        if(k2 != null) return true;
        return false;
    }
}
